package org.example.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.example.pojo.DApartment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.pojo.DStaff;
import org.example.pojo.select.DApartmentSelect;

import java.util.List;
import java.util.Map;

/**
* @author chenhongkai
* @description 针对表【d_apartment】的数据库操作Mapper
* @createDate 2024-03-06 16:58:19
* @Entity org.example.pojo.DApartment
*/
public interface DApartmentMapper extends BaseMapper<DApartment> {

    public IPage<DApartment> selectAllApartments(Page<DApartment> page,@Param("dApartmentSelect") DApartmentSelect dApartmentSelect);
    public List<DApartment> selectAllApartments_2(@Param("dApartmentSelect") DApartmentSelect dApartmentSelect);
    public List<DStaff> getStaffsByApartmentId(DApartmentSelect dApartmentSelect);

    public void DeleteApartmentVacancy(String apartmentId);
    public void AddApartmentVacancy(String apartmentId);

    public Integer selectVacancyById(String apartmentId);

    void updateByApartmentId(DApartment apartment);

    Long selectEmptyApartment();

    List<DApartment> selectApartmentInfo();

    List<Map> selectApartmentTypes();

    List<DApartment> selectAllAndAll(@Param("dApartment") DApartment dApartment);

    Long getVacancyTotal(@Param("dApartment") DApartment dApartment);


//    @Select("<script>" +
//            "select a.apartment_id,a.building_id,a.apartment_type,a.number_of_people," +
//            "(select s.staff_name + ',' from d_staff s where s.apartment_id=a.apartment_id  FOR XML PATH('')) as dStaffs  " +
//            "from d_apartment a where a.apartment_id " +
//            "like CONCAT('%', #{apartmentId}, '%') " +
//            "and building_id like CONCAT('%',#{buildingId},'%') " +
//            "</script>")
//    public List<DApartment> SelectAllApartments(DApartmentSelect dApartmentSelect);
//
//    @Select("select * from d_apartment where apartment_id = #{apartment_id} ")
//    public List<DApartment> SelectApartment_byApartmentId(int apartment_id);
}





